package bb.lanxing.lib.devices.common;

import android.text.TextUtils;
import bb.lanxing.lib.devices.api.DeviceProvider;
import bb.lanxing.lib.devices.api.SmartDevice;
import java.util.ArrayList;
import java.util.List;

public class DefaultDeviceProvider implements DeviceProvider {
    private List<SmartDevice> mDevices = new ArrayList();

    @Override
    public boolean isAutoConnectDeviceType(int i) {
        return false;
    }

    @Override
    public boolean isSecondGenerationDevice(int i) {
        return false;
    }

    @Override
    public boolean isSensorDevice(int i) {
        return false;
    }

    @Override
    public void removeByType(int i) {
    }

    @Override
    public void removeByTypeAndFlag(int i, int i2) {
    }

    @Override
    public SmartDevice create() {
        return new DeviceInfo();
    }

    @Override
    public List<SmartDevice> getDevicesByType(int i) {
        ArrayList arrayList = new ArrayList();
        for (SmartDevice smartDevice : this.mDevices) {
            if (smartDevice.getType() == i) {
                arrayList.add(smartDevice);
            }
        }
        return arrayList;
    }

    @Override
    public SmartDevice getDeviceByAddress(String str) {
        if (TextUtils.isEmpty(str)) {
            return null;
        }
        for (SmartDevice smartDevice : this.mDevices) {
            if (str.equals(smartDevice.getAddress())) {
                return smartDevice;
            }
        }
        return null;
    }

    @Override
    public void save(SmartDevice smartDevice) {
        if (!this.mDevices.contains(smartDevice)) {
            this.mDevices.add(smartDevice);
        }
    }

    @Override
    public List<SmartDevice> getDevices() {
        return new ArrayList(this.mDevices);
    }
}
